package com.film.service.impl.movie;

import com.alibaba.fastjson.JSONObject;
import com.film.service.movie.DeleteMovieCommentService;
import com.film.utils.MySqlConnection;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.sql.Statement;

@Service
public class DeleteMovieCommentServiceImpl implements
             DeleteMovieCommentService {
    @Override
    public JSONObject delete(Integer movieId,Integer commentatorId)
        throws SQLException {
        JSONObject resp = new JSONObject();
        try {
            String sql = "delete from Movie_Comments where movie_id = " + movieId
                     + " and commentator_id = " + commentatorId;
            System.out.println(sql);
            Statement stmt = MySqlConnection.connect.createStatement();
            stmt.execute(sql);
            stmt.close();
            resp.put("message", "删除成功");
        } catch (SQLException e) {
            e.printStackTrace();
            resp.put("message", "删除失败");
        }
        return resp;
    }
}
